<?php

     define('ACC',true);
require_once('./include/init.php');

     $goods_id = $_GET['goods_id'];

     //获取单个栏目的商品详情
     $goods = new goodModel();
     $dataDetail = $goods->getoneGoods($goods_id);

     //获取面包屑导航，也就是 栏目的层级结构， 找家谱树
      $cat = new catModel();
      $parenTree = array_reverse($cat->getparent($dataDetail['cat_id']));

      //用cookie 做个商品浏览历史功能
      if(isset($_COOKIE['history'])){
          $his = explode(',',$_COOKIE['history']);
          array_unshift($his,$goods_id);
          $his = array_unique($his);
          setcookie('history', implode(',',$his));
      }else{
          setcookie('history',$goods_id);
      }

      //从数据库取出浏览历史里的商品
       $historyGoods = $goods->getHistory(10);

      //清除历史浏览记录 history
      if(isset($_GET['clear']) && $_GET['clear']){
          setcookie('history', '',0);
          header('location: ./goods.php?goods_id='.$goods_id);
      }


//      print_r(array_reverse($parenTree));


require_once('./view/front/shangpin.html');


?>